!JObj.Plugin && (JObj.Plugin = {});

JObj.use('JModalLayer');
JObj.plugin('JTrackBar');

JObj.Plugin.JSlideShow = {};

(function($){

    var vars = {
        created:false,
        skinloaded:false,
        imgs:[],
        imgs_:[],
        idx:[],
        curr:null
    };

    var objs = {
        ml:JObj.UI.JModalLayer,
        tb:null,
        outline:null,
        panel:null,
        btnArea:null,
        btnPre:null,
        btnNext:null,
        btnPlay:null,
        btnOrg:null,
        btnClose:null
    };


    var index = function(){
        
    }


    /**
     * arr = {
     *  path:{icon:path | null,desc:description | null,link:href | null},
     *  path:{icon:path | null,desc:description | null,link:href | null},
     *  ....
     * };
     * @param arr
     */
    $.bind = function(arr){
        vars.imgs = arr;
    }

    /*$.bindFromHTML = function(){
        var imgs = document.images;
        var img,i;
        for(i=0;img = imgs[i];i++){
            
        }
    }*/

    $.preLoad = function(){
        var path,img;

        for(path in vars.imgs){
            img = new Image();
            img.src = path;
            //vars.imgs.push(img);
        }
    }

    var create = function(){
        objs.outline = JObj.$c('DIV');
        objs.ml.getLayer().appendChild(objs.outline);
        objs.outline.className = 'JSlideShowDefault';

        objs.panel = JObj.$c('DIV');
        objs.outline.appendChild(objs.panel);
        objs.panel.className = 'panel';

        objs.tb = JObj.Plugin.JTrackBar.getInstance('H',183,objs.panel);
        objs.tb.create();
		objs.tb.setDivision(1,10);

        objs.btnArea = JObj.$c('UL');
        objs.panel.appendChild(objs.btnArea);
        objs.btnArea.className = 'btnArea';

        var t = JObj.$c('LI');
        objs.btnArea.appendChild(t);
        t.className = 'btnPre';
        objs.btnPre = JObj.$c('A');
        t.appendChild(objs.btnPre);
        objs.btnPre.href="javascript:doAA()";
		objs.btnPre.innerHTML = '&nbsp;';

        t = t.cloneNode(true);
        objs.btnArea.appendChild(t);
        t.className = 'btnPlay';
        objs.btnPlay = t.firstChild;

        t = t.cloneNode(true);
        objs.btnArea.appendChild(t);
        t.className = 'btnNext';
        objs.btnNext = t.firstChild;

        t = t.cloneNode(true);
        objs.btnArea.appendChild(t);
        t.className = 'btnOrg';
        objs.btnOrg = t.firstChild;
		
        t = t.cloneNode(true);
        objs.btnArea.appendChild(t);
        t.className = 'btnList';
        objs.btnOrg = t.firstChild;		

        t = t.cloneNode(true);
        objs.btnArea.appendChild(t);
        t.className = 'btnClose';
        objs.btnClose = t.firstChild;

        vars.created = true;
    }

    $.show = function( ){
        if(!vars.skinloaded){
            JObj.Loader.loadCss(JObj.path + '/plugins/JSlideShow/default/skin.css');
            vars.skinloaded = true;
        }
        
        objs.ml.show();
        if(!vars.created) create();
    }

})(JObj.Plugin.JSlideShow);